<template>
    <slot :controller="controller" :store="store" :model="model" :noPadding="noPadding">
        <div :id="controlID" :name="model.codeName" :class="classNames" style="">
            <AppDashboard v-bind="$attrs" :noPadding="noPadding" :layoutOpts="model.layoutOpts">
                <slot name="IBIZBOOKDashboardView_layoutdashboard_container1Portlet" :controller="controller" :store="store" :model="model" :actions="{ handleCtrlInit, handleCtrlAction, handleCtrlDestroy }">
                    <IBIZBOOKDashboardView_layoutdashboard_container1Portlet
                        name="dashboard_container1"
                        :context="store.context"
                        :viewParams="store.viewParams"
                        :pLoadingHelper="store.loadingHelper"
                        :pViewCtx="store.viewCtx"
                        @ctrl-init="(name:string, ability:any) => { handleCtrlInit(controller, name, ability) }"
                        @ctrl-action="(name:string, action:any, data:any) => { handleCtrlAction(controller, name, action, data) }"
                        @ctrl-destroy="(name:string, data:any) => { handleCtrlDestroy(controller, name, data) }"
                    />
                </slot>
            </AppDashboard>
        </div>
    </slot>
</template>
<script setup lang="ts">
// 基于template/src/widgets/{{appEntities}}/{{ctrls@DASHBOARD}}-dashboard/{{spinalCase ctrl.codeName}}-dashboard-base.vue.hbs生成
import { AppDashboard } from '@components/widgets/dashboard';
import { useProps, useBasic, useAction, useController } from './usr-2-dashboard-hook';
import { DashboardActionType, IDashboardAbility, IDashboardStore, IParam } from "@/core/interface";
import IBIZBOOKDashboardView_layoutdashboard_container1Portlet from '@widgets/ibizbook/usr-2-dashboard-view-layoutdashboard-container-1-portlet/usr-2-dashboard-view-layoutdashboard-container-1-portlet.vue';
// 输入参数
const props = defineProps(useProps());

// 基础数据
const { 
    model,
    controlID, 
    getClassNames, 
    useNavParamsBind, 
    useEventBind, 
    handleCtrlDestroy,
    handleCtrlInit, 
    handleCtrlAction,
} = useBasic(props);

const emit = defineEmits<{
    (event: 'ctrl-action', name: string, action: DashboardActionType, data: IParam[]): void;
    (event: 'ctrl-init', name: string, data: IDashboardAbility): void;
    (event: 'ctrl-destroy', name: string, data: IParam): void;
}>();

const evt = useEventBind(emit);
const classNames = computed(() => {
    return getClassNames(props);
});

const controller = useController(props, evt, { controlID });

useNavParamsBind(controller, props);

const store: IDashboardStore = controller.getStore();

onMounted(() => {
    controller.ctrlMounted();
});

onUnmounted(() => {
    controller.ctrlDestroy();
})
</script>